<!DOCTYPE html>
<%@page isELIgnored="false"%>
<html lang="en">
<head>
  <meta charset="utf-8" >
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="ThemeBucket">
  <link rel="shortcut icon" th:href="@{#}" type="image/png">

  <title>商品添加</title>

    <link rel="stylesheet" type="text/css" th:href="@{/css/bootstrap-fileupload.min.css}" />
    <div th:include="common :: commonheader"/>
</head>

<body class="sticky-header">

<section>
    <!-- left side start-->
    <div th:replace="common :: #leftmenu " ></div>
    <!-- left side end-->
    
    <!-- main content start-->
    <div class="main-content" >

        <!-- header section start-->
        <div th:replace="common :: headermenu" ></div>
        <!-- header section end-->

        <!-- page heading start-->
        <div class="page-heading">
            <h3>
                商品添加
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a th:href="@{/main.html}">首页</a>
                </li>
                <li>
                    <a th:href="@{/product/list}">商品管理</a>
                </li>
                <li class="active">商品添加</li>
            </ul>
        </div>
        <!-- page heading end-->

        <!--body wrapper start-->
        <div class="wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <header class="panel-heading">
                            商品添加
                        </header>
                        <div class="panel-body">
                            <div class="form">
                                <form class="cmxform form-horizontal adminex-form" id="signupForm" method="post" th:action="@{/product/save}" enctype="multipart/form-data">
                                    <div class="form-group ">
                                        <label for="product_name" class="control-label col-lg-2">产品名称</label>
                                        <div class="col-lg-10">
                                            <input type="hidden" name="id" th:value="${product.id}">
                                            <input type="hidden" name="productNum" th:value="${product.productNum}">
                                            <input th:value="${product.productName}" th:placeholder="${product.productName}" class=" form-control" id="product_name" name="productName" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="price" class="control-label col-lg-2">产品价格</label>
                                        <div class="col-lg-10">
                                        <div class="input-group m-bot15" >
                                            <span class="input-group-addon">$</span>
                                            <input th:value="${product.price}" th:placeholder="${product.price}" type="text" class="form-control" name="price" id="price">
                                            <span class="input-group-addon ">.00</span>
                                        </div>
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="reserve" class="control-label col-lg-2">库存</label>
                                        <div class="col-lg-10">
                                            <input th:value="${product.reserve}" th:placeholder="${product.reserve}" class="form-control " id="reserve" name="reserve" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="city" class="control-label col-lg-2">城市</label>
                                        <div class="col-lg-10">
                                            <input th:value="${product.city}" th:placeholder="${product.city}" class=" form-control" id="city" name="city" type="text" />
                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="img" class="control-label col-lg-2">上传图片</label>
                                        <div class="col-lg-10">

                                                <div class="fileupload fileupload-new" data-provides="fileupload">

                                                    <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
                                                        <img th:src="${product.img}" alt="" />
                                                    </div>
                                                    <div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
                                                    <div>
                                                   <span class="btn btn-default btn-file">
                                                   <span class="fileupload-new"><i class="fa fa-paper-clip"></i>选择图片</span>
                                                   <span class="fileupload-exists"><i class="fa fa-undo"></i> 更换</span>
                                                   <input type="file" class="default" name="productImg" id="img" formenctype="multipart/form-data" th:value="${product.img}"/>
                                                   </span>
                                                        <a href="#" class="btn btn-danger fileupload-exists" data-dismiss="fileupload"><i class="fa fa-trash"></i> 移除</a>
                                                    </div>

                                                </div>


                                        </div>

                                    </div>
                                    <div class="form-group ">
                                        <label for="open"  class="control-label col-lg-2">状态</label>
                                        <div class="col-lg-10">
                                            <div class="radio">
                                                <label>
                                                    <input  type="radio" name="productStatus" id="open" value="1" checked/>
                                                    出售
                                                </label>
                                            </div>
                                            <div class="radio">
                                                <label>
                                                    <input  type="radio" name="productStatus" id="close" value="0" th:checked="${product.productStatus eq 0}"/>
                                                    暂缺
                                                </label>
                                            </div>

                                        </div>
                                    </div>
                                    <div class="form-group ">
                                        <label for="productDesc" class="control-label col-lg-2">产品详情</label>
                                        <div class="col-lg-10">
                                            <div class="panel-body">

                                                    <div class="form-group">

                                                            <textarea rows="6" class="form-control" id="productDesc" name="productDesc" th:placeholder="${product.productDesc}" ></textarea>

                                                    </div>

                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-lg-offset-2 col-lg-10">
                                            <button class="btn btn-primary" type="submit" >Save</button>
                                            <button class="btn btn-default" type="button" onclick="jump()">Cancel</button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </section>
                </div>
            </div>
        </div>
        <!--body wrapper end-->

        <!--footer section start-->
        <footer>
            2020 &copy; AdminEx by ThemeBucket </a>
        </footer>
        <!--footer section end-->


    </div>
    <!-- main content end-->
</section>

<!-- Placed js at the end of the document so the pages load faster -->
<div th:include="common :: #commonscript" />

<!--<script type="text/javascript" th:src="@{/js/jquery.validate.min.js}"></script>-->
<!--<script th:src="@{/js/validation-init.js}"></script>-->

<script th:src="@{/js/spinner-init.js}"></script>
<script type="text/javascript" th:src="@{/js/bootstrap-fileupload.min.js}"></script>

<script th:inline="javascript">
    function jump(){
        window.location.href="/product/list";
    }

    function checkForm(){
        var form = document.getElementById('signupForm');
        return true;
    }

    document.getElementById("productDesc").value=[[${product.productDesc}]];
</script>
</body>
</html>
